﻿using DevExpress.XtraEditors;
using GnpFine.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GnpFine.StartUI.WinFormFu
{
    public partial class RegServices : DevExpress.XtraEditors.XtraForm
    {
        public RegServices()
        {
            InitializeComponent();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            string tz = textEdit1.Text.Trim();
            string pk = CryptogramUtil.ReadPublicKey(AppContext.BaseDirectory + "\\PublicKeyPath.xml");
            string pm = CryptogramUtil.RSAEncrypt(tz, pk);
            memoEdit1.Text = pm;
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            string zcm = memoEdit2.Text.Trim();

            string pk = CryptogramUtil.ReadPrivateKey(AppContext.BaseDirectory + "\\PrivateKeyPath.xml");

            textEdit2.Text = CryptogramUtil.RSADecrypt(zcm,pk );
            string mx = textEdit2.Text;
            MessageBox.Show(mx.Split('|')[0]);
            MessageBox.Show(mx.Split('|')[1]);
            MessageBox.Show(mx.Split('|')[2]);
        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            CryptogramUtil.getRSAKey(AppContext.BaseDirectory + "\\PrivateKeyPath.xml",
                AppContext.BaseDirectory + "\\PublicKeyPath.xml");
            memoEdit4.Text = CryptogramUtil.ReadPublicKey(AppContext.BaseDirectory + "\\PublicKeyPath.xml");
            memoEdit3.Text = CryptogramUtil.ReadPrivateKey(AppContext.BaseDirectory + "\\PrivateKeyPath.xml");
        }

  
    }
}